package com.fuyao.cloud.personnel.problem.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyao.cloud.common.core.util.R;
import com.fuyao.cloud.common.excel.annotation.ResponseExcel;
import com.fuyao.cloud.common.log.annotation.SysLog;
import com.fuyao.cloud.personnel.api.entity.TenderBasicSituation;
import com.fuyao.cloud.personnel.problem.service.TenderBasicSituationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 招标基本情况表
 *
 * @author hyc
 * @date 2022-05-20 10:53:06
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/tenderbasicsituation" )
@Api(value = "tenderbasicsituation", tags = "招标基本情况表管理")
public class TenderBasicSituationController {

    private final TenderBasicSituationService tenderBasicSituationService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param tenderBasicSituation 招标基本情况表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
//    @PreAuthorize("@pms.hasPermission('tender_basic_situation_view')" )
    public R getFyTenderBasicSituationPage(Page page, TenderBasicSituation tenderBasicSituation) {
        return R.ok(tenderBasicSituationService.page(page, Wrappers.query(tenderBasicSituation)));
    }


    /**
     * 通过id查询招标基本情况表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
//    @PreAuthorize("@pms.hasPermission('tender_basic_situation_view')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(tenderBasicSituationService.getById(id));
    }

    /**
     * 新增招标基本情况表
     * @param tenderBasicSituation 招标基本情况表
     * @return R
     */
    @ApiOperation(value = "新增招标基本情况表", notes = "新增招标基本情况表")
    @SysLog("新增招标基本情况表" )
    @PostMapping
//    @PreAuthorize("@pms.hasPermission('tender_basic_situation_add')" )
    public R save(@RequestBody TenderBasicSituation tenderBasicSituation) {
        return R.ok(tenderBasicSituationService.save(tenderBasicSituation));
    }

    /**
     * 修改招标基本情况表
     * @param tenderBasicSituation 招标基本情况表
     * @return R
     */
    @ApiOperation(value = "修改招标基本情况表", notes = "修改招标基本情况表")
    @SysLog("修改招标基本情况表" )
    @PutMapping
//    @PreAuthorize("@pms.hasPermission('tender_basic_situation_edit')" )
    public R updateById(@RequestBody TenderBasicSituation tenderBasicSituation) {
        return R.ok(tenderBasicSituationService.updateById(tenderBasicSituation));
    }

    /**
     * 通过id删除招标基本情况表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除招标基本情况表", notes = "通过id删除招标基本情况表")
    @SysLog("通过id删除招标基本情况表" )
    @DeleteMapping("/{id}" )
//    @PreAuthorize("@pms.hasPermission('tender_basic_situation_del')" )
    public R removeById(@PathVariable Long id) {
        return R.ok(tenderBasicSituationService.removeById(id));
    }


    /**
     * 导出excel 表格
     * @param fyTenderBasicSituation 查询条件
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
//    @PreAuthorize("@pms.hasPermission('tender_basic_situation_export')" )
    public List<TenderBasicSituation> export(TenderBasicSituation fyTenderBasicSituation) {
        return tenderBasicSituationService.list(Wrappers.query(fyTenderBasicSituation));
    }
}
